<template>
  <div style="background: #fff;padding-bottom:60px;">
    <supplier-header :loginSucc='loginSucc'></supplier-header>
    <div class="blockBanner">
      <el-carousel trigger="click">
        <el-carousel-item v-for="item in bannerList" :key="item">
          <img :src="item">
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="wrap">
      <div class="r-con">
        <div class="home-login" v-if="!userInfo.username">
          <h4 style="text-align: left;">供应商登录</h4>
          <el-form
            :model="loginForm"
            size="small"
            status-icon
            ref="ruleForm2"
            label-width="50px"
            class="supplierLoginForm"
          >
            <el-form-item label="账号" prop="age">
              <el-input v-model="loginForm.name" placeholder="请输入手机号"></el-input>
              <!-- <el-input v-model="loginForm.name" placeholder="请输入用户名"></el-input> -->
            </el-form-item>
            <el-form-item label="密码" prop="checkPass">
              <el-input
                type="password"
                v-model="loginForm.pass"
                auto-complete="off"
                placeholder="请输入密码"
              ></el-input>
            </el-form-item>
            <el-form-item label-width="0">
              <el-button class="supplierLogin" @click="supplierLogin">立即登录</el-button>
            </el-form-item>
          </el-form>
        </div>
        <div class="tobid" v-if="userInfo.username">
          <el-button size="small" @click="bmToBid" style="width:100%" type="primary">去投标</el-button>
        </div>

      </div>
      <div class="l-con">
        <div class="inf-list">
          <h4>
            <router-link :to="{ path: '/bidFunMessage' }">查看更多>></router-link>
            <span>招标公告</span>
          </h4>
          <ul class="gg">
            <li v-for="(item, index) in tenderFileList" :key="index">
              <!-- <span v-if="dayFn(myDate-item.SUBMIT_TENDER_DOCUMENT_END) == '已结束'" class="btn-over">投标截止</span>
              <a class="btn-bm" v-if="dayFn(myDate-item.SUBMIT_TENDER_DOCUMENT_END) != '已结束'" @click="bmToBid">投标</a> -->

              <em class="time" v-if="dayFn(item.tender.endtime-myDate) != '已结束'" @click="tolive()">{{dayFn(item.tender.endtime-myDate)}}</em>
              <em class="time" v-if="dayFn(item.tender.endtime-myDate) == '已结束'">已结束</em>

              <a class="ggMain" @click="lookDetail(item)">
                <i>●</i>{{item.tender.tendername}}
              </a>
            </li>
            <!-- <li>
              <a class="btn-bm" @click="bmToBid">投标</a>
              <em class="time">倒计时：12天</em>
              <a class="ggMain" @click="lookDetail">
                <i>●</i>当代置业集团2016-2017年度工程造价复审集采招标公告2017年度工程造价复审集采招标公告
              </a>
            </li> -->
          </ul>
        </div>
        <div class="inf-list">
          <h4>
            <router-link :to="{ path: '/bidWinMessage' }">查看更多>></router-link>
            <span>中标公告</span>
          </h4>
          <ul>
            <li v-for="(item, index) in tenderWinList" :key="index">
              <a :title="item.tender.tendername">
                <i>●</i>{{item.tender.tendername}}
              </a>
            </li>
          </ul>
        </div>
      </div>
      <div class="clear" style="width:100%;height:1px;clear:both;font-size:0px;"></div>
    </div>
    <div class="footer">

<ul>
<li>
采购投诉反馈
</li>

<li>
廉洁举报电话：<img src="static/images/phone.png" style="vertical-align: middle;">010-669878-878
</li>

<li>
廉洁举报邮箱：<img src="static/images/email.png" style="vertical-align: middle;"> XXXXXXX.com.cn
</li>

<li>
廉洁举报信件邮寄地址：<img src="static/images/address.png" style="vertical-align: middle;">福建省新罗区东肖北路1号10号楼3层
</li>

<li>
邮编：364000
</li>
</ul>
    <span>版权所有Copyright@2016资产管理平台</span>
    </div>
    <gg-detail :detailData="detailData"></gg-detail>
  </div>
</template>

<script>
import Vue from "vue";
import store from '../../store/store';
import http from '../../utils/http';
export default {
  data() {
    return {
      loginForm: {
        pass: "",
        name: ""
      },
      userInfo: {},
      loginSucc: false,
      detailData: {
        isShow: false,
        code: ""
      },
      tenderFileList: [{
        tender:{
          'endtime-myDate':"2021-9-10",
          tendername:"龙岩学院（东肖、凤凰）物业委托管理服务类采购项目招标公告[第三次]"
        },
      },
      {
        tender:{
          'endtime-myDate':"2021-9-10",
          tendername:"龙岩学院大学科技园LED全彩屏项目（二次询价采购）结果公告"
        },
      },
      {
        tender:{
          'endtime-myDate':"2021-9-10",
          tendername:"龙岩学院教学科研大楼6、7层木门改防盗门项目主材询价公示"
        },
      },{
        tender:{
          'endtime-myDate':"2021-9-10",
          tendername:"龙岩学院教务处2021多媒体教室设备升级改造建设项目货物类采购项目结果公告(包1)"
        },
      }],
      tenderFileListData: {
        pageNum: 1,
        pageSize: 8,
        tenderFileCode: ""
      },
      tenderWinList: [{
        tender:{
          'endtime-myDate':"2021-9-20",
          tendername:"龙岩学院大学科技园LED全彩屏项目结果公告"
        },
      },
      {
        tender:{
          'endtime-myDate':"2021-9-10",
          tendername:"龙岩大学科技园墙体户外标识二次询价采购结果公示"
        },
      },
      {
        tender:{
          'endtime-myDate':"2021-9-10",
          tendername:"龙岩学院生命科学学院实验室设备采购项目结果公示"
        },
      },{
        tender:{
          'endtime-myDate':"2021-9-10",
          tendername:"龙岩学院教务处2021多媒体教室设备升级改造建设项目货物类采购项目结果公告(包1)"
        },
      }],
      tenderWinListData: {
        pageNum: 1,
        pageSize: 8
      },
      bannerList: [
        'static/images/banner1.jpg',
        'static/images/banner2.png',
      ],
      myDate: '',
    };
  },
  mounted() {
    localStorage.setItem("achao_token","")
    document.title = '资产管理平台';
    if(sessionStorage.getItem('supplierLoginInfo')){
          this.userInfo = JSON.parse(sessionStorage.getItem('supplierLoginInfo'));
      } else {
          this.userInfo = {};
      }
    this.tenderFileListFn();
    this.tenderWinListFn();
    var date = new Date().getTime()
    this.myDate = date;
    // console.log(this.myDate)
  },
  methods: {
    tolive(){
      this.$router.push('/live');
    },
    dayFn(time){
      this.currentindex++;
      time = time + 57600000;
      // console.log(time)
      if(time>0){
        var day = time/1000/60/60/24;
        day = Math.floor(day);
        return day;
      } else {
        return '直播中'
      }

    },
    supplierLogin() {
      this.$api.modular
        .getSupLogin(this.loginForm)
        .then(res => {
          if(res.status == 200){
            if(res.data.code == 200){
              this.$message.success('登录成功！');
              this.userInfo = res.data.data;
              this.loginSucc = true;
              // console.log(this.loginSucc)
              sessionStorage.setItem('supplierLoginInfo', JSON.stringify(this.userInfo));
              var token = res.data.data.slice(7);
              // var state =null;
              console.log(token)
              if (token != ""){
              // 后端API验证通过
              // 调用上面mutations里定义的方法
              // store.commit("token",{store,"token":token});
                localStorage.setItem("achao_token",token)

                // console.log(sessionStorage.getItem("achao_token")+"123456")
              }
              this.$router.push({
                name: "startBid"
              });
            } else {
              this.$message.error('登录失败！');
            }
          }
        })

    },
    bmToBid() {
      this.$router.push({
        name: "startBid",
      });
    },
    lookDetail(row) {
      if (!this.userInfo.username) {
        this.$message.error("请先登录！");
        return false;
      }
      this.detailData.isShow = true;
      this.detailData.code = row.tender.tenderid;
    },
    tenderFileListFn() {
      this.$api.modular.tenderFileList(this.tenderFileListData).then(res => {
        if(res.status == 200){
          if(res.data.code == 200){
            this.tenderFileList = res.data.data.list;
          } else {
            this.$message.error(res.data.message);
          }
        } else {
          this.$message.error(res.message);
        }

      });
    },

    tenderWinListFn() {
      this.$api.modular.tenderWinList(this.tenderWinListData).then(res => {
        if(res.status == 200){
          if(res.data.code == 200){
            this.tenderWinList = res.data.data.list;
          } else {
            this.$message.error(res.data.message);
          }
        } else {
          this.$message.error(res.message);
        }
      });
    }
  }
};
</script>
<style>
.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
}
h1,h2,h3,h4,h5,h6,ul,li,p,span{
  margin: 0;
}
li{
  list-style: none;
}
.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
.blockBanner {
  width: 70%;
  height: 360px;
  position: relative;
  margin:0 auto;
  overflow: hidden;
  border-top: 1px solid #ccc;
}
.blockBanner .el-carousel__container{
  height:  360px;
}
.blockBanner img{
  float: left;
  width: 100%;
  height: 360px;
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, 0);
}
.wrap {
  width: 1170px;
  margin: 0 auto;
}

.r-con {
  float: right;
  width: 310px;
}
.home-login {
  overflow: hidden;
  font-size: 12px;
}
.home-login h4 {
  font-size: 14px;
  border-bottom: 1px solid #cf001b;
  line-height: 36px;
  font-weight: normal;
  padding-left: 5px;
  margin-bottom: 8px;
}
.home-login h4 .btn-reg {
  height: 36px;
  display: block;
  padding-right: 18px;
  float: right;
  color: #cf001b;
  font-size: 12px;
}
.home-login p {
  border-bottom: 1px solid #ededed;
  height: 50px;
  line-height: 50px;
  font-size: 13px;
}
.home-login .input-user {
  height: 50px;
  border: none;
  font-size: 12px;
  padding-left: 50px;
  width: 80%;
}
.home-login .input-password {
  height: 50px;
  border: none;
  font-size: 12px;
  padding-left: 50px;
  width: 80%;
}
.home-login .look a {
  padding: 15px 0 30px;
  display: block;
  font-size: 14px;
  color: #cf001b;
}
.home-login .btn-login {
  height: 38px;
  line-height: 38px;
  background: #cf001b;
  border-radius: 4px;
  display: block;
  border: none;
  color: #fff;
  font-size: 15px;
  text-align: center;
  width: 100%;
  cursor: pointer;
}

.l-con {
  margin-right: 364px;font-size: 12px;
}
.l-con .inf-list {
  margin: 8px 0 0;
  overflow: hidden;
}
.l-con .inf-list h4 {
  font-size: 14px;
  border-bottom: 1px dotted #ccc;
  line-height: 34px;
  font-weight: normal;
  float: left;
  width: 100%;
}
.l-con .inf-list h4 a {
  float: right;
  color: #cf001b;
  font-weight: normal;
  font-size: 12px;
}
.l-con .inf-list h4 span {
  float: left;
}
.l-con .inf-list ul {
  padding: 10px 0;
  width: 100%;
  float: left;
  margin: 0;
  max-height: 256px;
  overflow: auto;
}
.l-con .inf-list ul.gg li {
  width: 100%;
  margin-right: 0;
  float: left;
  line-height: 32px;
  height: 32px;
  color: #575757;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: keep-all;
}
.l-con .inf-list ul.gg li a.ggMain {
  width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: keep-all;
}
.l-con .inf-list ul.gg li a.ggMain:hover {
  cursor: pointer;
}
.l-con .inf-list ul li {
  width: 48%;
  float: left;
  margin-right: 2%;
  line-height: 32px;
  height: 32px;
  color: #575757;
}
.l-con .inf-list ul li a {
  float: left;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: keep-all;
  text-align: left;
  width: 100%;
}
.l-con .inf-list ul li i {
  color: #cf001b;
  font-size: 10px;
  padding-right: 6px;
}
.l-con .inf-list ul li .time {
  float: right;
  width: 140px;
  text-align: right;
  padding-right: 6px;
  font-size: 12px;
}
.l-con .inf-list ul li .btn-bm {
  border-radius: 25px;
  background: #cf001b;
  height: 24px;
  line-height: 24px;
  width: 67px;
  float: right;
  text-align: center;
  color: #fff;
  font-size: 12px;
}
.l-con .inf-list ul li .btn-over {
  border-radius: 25px;
  background: #b0b0b0;
  height: 24px;
  line-height: 24px;
  width: 67px;
  float: right;
  text-align: center;
  color: #fff;
  font-size: 12px;
}
.home-login .login-success {
  width: 100%;
  height: 178px;
  text-align: center;
  margin-top: -7px;
}
.home-login .login-success .company {
  text-align: center;
  height: 60px;
  line-height: 22px;
  padding-top: 46px;
  display: block;
  font-size: 13px;
}
.complaint {
  border: 1px solid #ededed;
  margin-top: 16px;font-size: 12px;
}
.complaint h4 {
  height: 35px;
  line-height: 35px;
  padding-left: 10px;
  background: #f0f0f0;
  font-size: 14px;
  font-weight: normal;
}
.complaint p {
  padding: 20px;
  line-height: 30px;
}
.supplierLoginForm {
  margin-top: 20px;
}

.supplierLoginForm .el-input__inner, .supplierLoginForm .el-form-item__label{
  font-size: 12px;
}
.supplierLogin {
  width: 100%;
  background: #cf001b;
  color: #fff;
  border: none;
}
.supplierLogin:hover,
.supplierLogin:focus {
  background: #cf001b;
  color: #fff;
  border: none;
}
.btn-bm:hover {
  cursor: pointer;
}
.el-carousel__indicator.is-active button{
  background: #cf001b;
  opacity: 1;
}
.el-carousel__button{
  width: 60px;
  height: 4px;
}
.el-carousel__indicators--horizontal{
  bottom: 14px;
}
.el-carousel__item img{
  display: block;
  width: 100%;
  margin: 0 auto;
}
.el-carousel__arrow{
  width: 50px;
  height: 50px;
  font-size: 20px;
}

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 88;
  width: 100%;
  background: #3e3e3e;
  text-align: center;
  height: 150px;
  line-height: 42px;
  color: #fff;
  min-width: 1170px;
  margin-top: 20px;
}

body{
  background: #fff;
}
ul{
    font-size: 14px;
    width: 580px;
    margin: 0 auto;
}
ul>li{
  /* float:left; */
  /* text-align:center; */
  margin-right:10px;
}
ul::after{
     content:"";
     display:block;
     clear:both;
}
ul>li:hover{
  color:red;
}
.time{
  color:#6ca8fe !important;
}
</style>
